assume cs:code, ds:data

data segment
	db "Welcome to Masm!", 0
data ends


code segment
start:		mov ax, data
			mov ds, ax
			mov si, 0
			mov dh, 8 ;行号
			mov dl, 32 ;列号
			mov cl, 42h ;颜色
			call show_str

			mov ax, 4c00h
			int 21h


show_str:	push es
			push di
			push ax
			push si
			
			mov ax, 0B800h
			mov es, ax
			;计算行号 * 160
			mov al, 160
			mul dh
			mov di, ax ;将乘法的结果放到di中,乘法的结果最大不会超过4000

			;计算列号 * 2
			mov al, 2
			mul dl
			add di, ax ;行号 * 160 + 列号 * 2

s0:			cmp byte ptr [si], 0
			je s1
			mov al, [si]
			mov es:[di], al
			inc di
			mov es:[di], cl
			inc di
			inc si
			jmp short s0
		
s1:			pop si
			pop ax
			pop di
			pop es
			ret		

code ends

end start

